<?php
class Pageley_Tag_FormatNumber extends Pageley_Tag_Abstract {
    
    private $value;
    private $format;
    
    public function execute() {
        $factory = Pageley_Controller_Session_Factory::getInstance();
        $session = $factory->getSession();
        $locale = $session->getLocale();
        $decimalPoint = ",";
        if(Pageley_Util_String::startsWith($locale->getCode(), "en")) {
        	$decimalPoint = ".";
        }
        $decimals = Pageley_Util_String::length(Pageley_Util_String::substringAfter($this->format, "."));
        return number_format($this->value, $decimals, $decimalPoint, "");
    }
    
    public function setValue($value) {
        $this->value = $value;
    }
    
    public function setFormat($format) {
    	$this->format = $format;
    }
}